﻿

@{
    ViewBag.Title = "ListenAlbumPage";
    Layout = "~/Views/Shared/_LayoutPublic.cshtml";
    List<ListenMusic.Song_ServiceReference.SongAlbum> lst_song = ViewBag.songAlbum;
}

<script src="@Url.Content("../../Scripts/Playlist/popbox.js")" type="text/javascript"></script>
<script src="@Url.Content("../../Scripts/Playlist/stuHover.js")" type="text/javascript"></script>
<link href="@Url.Content("../../Styles/Playlist/popbox.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("../../Styles/Playlist/pro_dropdown_2.css")" rel="stylesheet" type="text/css" />
<link href="../../Styles/MusicPlayer.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../JWPlayer/jwplayer.js"></script>
@{
   // ListenMusic.Album_ServiceReference.Album album = ViewBag.album;
    List<ListenMusic.Playlist_ServiceReference.FavoritePlayList> lst_favaritesPlaylist = ViewBag.songInPlaylist;
 }
 <script type="text/javascript">
    $(document).ready(function () {
        
        var psd = {albumid : '@lst_song[0].AlbumID'};
           setInterval(function(){
                $.post('/listen/updateCountView_Album',psd, function(data){
                    
                });
           },35000);

        setInterval(function(){
            var parameter = {
                'albumid' : '@lst_song[0].AlbumID',
                'pageindex': 1
            };
            $.post('/comment/LoadAlbumComment',parameter,function(data){
                var detail = "";
                for(i = 0; i<data.length;i++)
                {
                    //alert(data[i].CommentContent);
                    detail += "<p class='content-comment'><span><img width=50px height=70px src=../../Images/Avatars/" + data[i].Picture + "/><label class='username-comment'>" + data[i].UserName + "</label>" + " : " + data[i].CommentContent + "</p><span>";
                }
                $('#exist-comment-album').html(detail);
                
            });
          },3000);
        $("#postcomment").click(function () {
            var comment = {
                'typeID' : 4,
                'Album_ID' : '@lst_song[0].AlbumID',
                'comment': $('#comment').val(),
            };
            $.post('/user_comment/post',comment,function(data)
               {
                if(data == true)
                {
                  document.getElementById("comment").value ='';
                }
                else
                {
                      $("#error-text").html(data);
                }
               }
            );
        })
    })

</script>   

<form action="/user_comment/post" method="post" id="frmalbum">
@Html.Hidden("typeID","4")
@Html.Hidden("songID",null)
@Html.Hidden("album_ID",lst_song[0].AlbumID)
@Html.Hidden("returnURL",ViewContext.HttpContext.Request.Url.PathAndQuery)
<div id="music-content-album">
    <div id="music-left-album">
        <div id="music-title-album">
            <ul class="pic-album" >   
                    <li><img src="../../Images/albums/@lst_song[0].Picture" alt="" width="190" height="210" /></li>
            </ul>  
            <ul class="title-details-album">
                    <li><h1>@lst_song[0].AlbumName</h1></li> 
                    <li><h4>Năm phát hành: @lst_song[0].ReleaseYear</h4></li>  
                    <li><h4>Lượt nghe: @lst_song[0].CountView</h4></li>  
            </ul>          
        </div>
        <div id="music-player-album">
                <div id="container-album"></div>                
                <div id="playlist_style">                    
                    <div class="playlist">    
                        <ul class="details-playlist-album">                   
                    @foreach (ListenMusic.Song_ServiceReference.SongAlbum s in lst_song)
                       {
                               <li>
                                    <a href="#" onclick="jwplayer().playlistItem(@lst_song.IndexOf(s))">@s.SongName</a>
                                      <div class='popbox'>
                @if (Session["user"] == null)   
                {
                    <a href="#login-box" class="login-window">
                    <img src='../../Images/Icons/add.png' alt="" width="14px" title="Thêm vào danh sách yêu thích" style='position:relative' />
                    </a>                      
                }
                else
                {
                    bool flag = true;
                    for (int j = 0; j < lst_favaritesPlaylist.Count(); j++)
                    {
                        if (lst_favaritesPlaylist[j].SongID.Equals(@s.SongID))
                        {
                            <a class='action-playlist-album' href='#'>
                                <img src='../../Images/Icons/check.png' alt="" style='width:14px;position:relative' />
                            </a>  
                            flag = false;
                            break;
                        }
                    }
                    if (flag == true)
                    {
                        <a class='open action-playlist-album' href='#'>
                            <img src='../../Images/Icons/add.png' alt="" title="Thêm vào danh sách yêu thích" style='width:14px;position:relative' />
                        </a>                       
                    }
                }
                <a href="@Url.Action("dowloadfile", "dowload", new { url = @s.SongURL })"><img src="../../Images/Icons/download.jpg" title="Tải bài hát về máy" width="16" height="16px" alt="" /></a>    
                <div class='collapse'>
                    <div class='box'>
                        <div class='arrow'></div>
                            <div class='arrow-border'></div>
                                <div class="input">      
                                     <ul id="nav">
                                        <li class="top"><a href="#nogo22" id="Playlist" class="top_link"><span class="down">Playlist</span></a>
		                                    <ul class="sub">
                                            @if (@Session["user"] != null)
                                            {
                                                foreach (ListenMusic.Playlist_ServiceReference.Playlist pl in ViewBag.playList)
                                                {
			                                        <li><a href='@Url.Action("AddMusic", "Playlist", new { songid = @s.SongID, plid = @pl.PlaylistID, returnUrl = Request.RawUrl })'>@pl.PlaylistName</a></li>
                                                }
                                            }
		                                    </ul>
	                                      </li>
                                      </ul>  
                                       <hr />
                                  <div>
                                    <ul>                                    
                                        <li>
                                            <input type="text" name="playlistname" />
                                        </li>
                                        <li>
                                            <a href="#" onclick="postft('/playlist/addplaylist')">Tạo Playlist</a>
                                        </li>
                                    </ul>
                                </div>
                                    <a href="#" class="close">Cancel</a>        
                            </div>
                        </div>
                    </div>
            </div>
                                </li>                               
                           
                       }
                        </ul>
                    </div>
                </div>
        </div>
        <div id="comments-album">
                <h3 class="title">Bình luận</h3>
                <div id="exist-comment-album">
            
                </div>
                 <div class="page_comment_number" >
                    @for (int i = 1; i < ViewBag.pageNumber; i++)
                    { 
                        <a href="#">@i</a>
                    }
                </div>
                <div id="new-comment-album">
                   <textarea name="comment" id="comment" title="Gửi bình luận cho bài hát này" cols="82" rows="5"></textarea>
                    <div id="error-text"></div>
                       
                     @if (Session["user"] == null)
                    {
                    <a href="#login-box" style="margin-left:550px; margin-bottom:15px;" class="login-window"  >Gửi bình luận</a>
                    }
                    else
                    {
                        
                       <input type="button" id="postcomment" style="margin-left:550px; margin-bottom:15px;" value="Gửi bình luận" />
                    }
                    
                </div>
            </div>  

      </div>
      <div id="music-right-album">            
            <div id="right-album-content">
                <h3 class="title">Có thể bạn muốn nghe</h3>
                <div>                
                @foreach (ListenMusic.Album_ServiceReference.View8_Random_Album vra in ViewBag.randomAlbum)
                { 
                 <ul class="right-content-details">
                    <li><a href="ListenAlbumPage?albumid=@vra.AlbumID"><h4 class="name-music">@vra.AlbumName</h4></a></li>
                    <li><a href="/song/searchsong_bysinger?pageindex=1&singerid=@vra.SingerID">@vra.SingerName</a></li>
                </ul>
                }  
            </div>
            </div>
      </div>
      </div>
</form>
<script type="text/javascript">    
        jwplayer("container-album").setup(
          {
          'flashplayer': '../../JWPlayer/player.swf',
          'skin' :'../../JWPlayer/Skin/lava.zip',
          'playlist.size': '0',
          'playlist.position': 'top',
          'controlbar':'top',
          'autostart': 'true',
          'playlist': [              
           @foreach (ListenMusic.Song_ServiceReference.SongAlbum s in ViewBag.songAlbum)
           {         
           @:{
           @:     'file': '../../Music/@s.SongURL',
           @:      'title': '@s.SongName',
            @:    'image': '../../Images/logo.png',
            @:    'width': 670,
             @:   'height': 50,
             @:   'volume': 80
            @: },
            }],
            repeat: 'list'
    });   
</script>

   